<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta content="IE=edge" http-equiv="X-UA-Compatible">
    <meta content="width=device-width, initial-scale=1.0" name="viewport">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        ul {
            width: 100%;
            display: flex;
            justify-content: center;
        }

        li {
            float: left;
            margin: 10px;
            list-style: none;
            width: 100px;
            height: 100px;
            background-color: pink;
        }

        h1 {
            text-align: center;
            line-height: 100px;
        }

        .basic {
            border: 5px solid #000;
        }

        .red {
            background-color: red;
        }

        .blue {
            background-color: blue;
        }

        .green {
            background-color: green;
        }
    </style>
</head>

<body>
    <div id="app">
        <ul>
            <li class="basic" :class="classArr[0]"></li>
            <li class="basic" :class="classArr[1]"></li>
            <li class="basic" :class="classArr[2]"></li>
            <li class="basic"></li>
        </ul>
        <ul>
            <li :class="mode" @click="fn">
                <h1>{{name}}</h1>
            </li>
            <li :class="mode" @click="fn">
                <h1>{{school.name}}</h1>
            </li>
        </ul>
    </div>

    <script src="../JS/vue.js"></script>
    <script>
        new Vue({
            el: '#app',
            data: {
                mode:'',
                classArr: ['red', 'blue', 'green'],
                name: '张三',
                school: {
                    name: '李四'
                }
            },
            methods: {
                fn() {
                    const index = Math.floor(Math.random() * 3)
                    this.mode = this.classArr[index]
                }
            },
        })
    </script>
</body>

</html>